package com.example.jdai.jdai.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;

import com.example.jdai.jdai.MyApplication;
import com.example.jdai.jdai.config.Config;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by hellopyj on 2017/1/9.
 */

public class DataLnfo extends BaseData{
    public static String INFO="info";
    //public static int STATUS=DataAll.WEIWS;
    public static String ID_FRONT=INFO+"_id_front";
    public static String ID_BEHIND=INFO+"_id_behind";
    public static String ID_H_FRONT=INFO+"_id_h_front";
    public static String ID_H_BEHIND=INFO+"_id_h_behind";
    public static String NAME=INFO+"_name";
    public static String STUDY=INFO+"_study";
//    public static String ADDRESS_S=INFO+"_address_s";
//    public static String ADDRESS_X=INFO+"_address_x";
//    public static String ADDRESS_Q=INFO+"_address_q";
    public static String QQ=INFO+"_qq";
    public static String ADDRESS_J=INFO+"_address_j";
    public static String ID_NUM=INFO+"_id_num";


    public static String K_FRONT="pic1";
    public static String K_BEHIND="pic2";
    public static String K_H_FRONT="pic3";
    public static String K_H_BEHIND="pic4";
//    public static String FRONT;
//    public static String BEHIND;
//    public static String H_FRONT;
//    public static String H_BEHIND;

    public static String INFO_STATUS=INFO+"_status";
    //public HashMap<String,String> data=new HashMap<>();
    public DataLnfo()
    {
        count=10;
        SharedPreferences sp=MyApplication.applicationContext.getSharedPreferences(Config.SP_NAME,Context.CONTEXT_RESTRICTED);
        data.put(ID_FRONT,sp.getString(ID_FRONT,""));
        data.put(ID_H_FRONT,sp.getString(ID_H_FRONT,""));
        data.put(ID_BEHIND,sp.getString(ID_BEHIND,""));
        data.put(ID_H_BEHIND,sp.getString(ID_H_BEHIND,""));
        data.put(ID_NUM,sp.getString(ID_NUM,""));
        data.put(NAME,sp.getString(NAME,""));
        data.put(STUDY,sp.getString(STUDY,""));
//        data.put(ADDRESS_S,sp.getString(ADDRESS_S,""));
//        data.put(ADDRESS_X,sp.getString(ADDRESS_X,""));
//        data.put(ADDRESS_Q,sp.getString(ADDRESS_Q,""));
        data.put(QQ,sp.getString(QQ,""));
        data.put(ADDRESS_J,sp.getString(ADDRESS_J,""));
        data.put(INFO_STATUS,sp.getString(INFO_STATUS,""));
    }
//    public void saveAll()
//    {
//        SharedPreferences sp=MyApplication.applicationContext.getSharedPreferences(Config.SP_NAME,Context.CONTEXT_RESTRICTED);
//        SharedPreferences.Editor editor=sp.edit();
//        editor.putString(ID_FRONT,data.get(ID_FRONT));
//        editor.putString(ID_H_FRONT,data.get(ID_H_FRONT));
//        editor.putString(ID_BEHIND,data.get(ID_BEHIND));
//        editor.putString(ID_H_BEHIND,data.get(ID_H_BEHIND));
//        editor.putString(ID_NUM,data.get(ID_NUM));
//        editor.putString(NAME,data.get(NAME));
//        editor.putString(STUDY,data.get(STUDY));
//        editor.putString(ADDRESS_S,data.get(ADDRESS_S));
//        editor.putString(ADDRESS_X,data.get(ADDRESS_X));
//        editor.putString(ADDRESS_Q,data.get(ADDRESS_Q));
//        editor.putString(ADDRESS_J,data.get(ADDRESS_J));
//        editor.commit();
//        //editor.putString(ID_FRONT,data.get(ID_FRONT));
//
//    }
//    public boolean dataCheck(){
//        int i=0;
//        for (Map.Entry<String, String> entry : data.entrySet()) {
//            Log.v(entry.getKey(),entry.getValue());
//            if(entry.getValue().isEmpty())
//                break;
//            i++;
//        }
//        if(i==11) {
//
//            // Log.v("ddddd",i+"");
//            //if(STATUS<1)
//
//            return true;
//        }
//        else {
//            Toast.makeText(MyApplication.applicationContext, "信息未填写完成", Toast.LENGTH_SHORT).show();
//            return false;
//        }
//
//    }
    //推送到服务器
    public void putToServer()
    {

    }
    public boolean saveAll()
    {
        super.saveAll();
        return dataCheck();
    }
    public boolean dataCheck() {
        boolean check=super.dataCheck();
        return check;

    }

}
